#!/usr/bin/env bash

if [[ "$1" == "shared" ]]; then
  echo "Building shared"
elif [[ "$1" == "static" ]]; then
  echo "Building static"
else
  echo "${0} :: Error :: Please pass static or shared"
  exit 1
fi

THISDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Listed in tier-order
declare -a pkgs=(
extra-cmake-modules
attica-qt5
karchive-qt5
kcodecs-qt5
kconfig-qt5
kcoreaddons-qt5
kdbusaddons-qt5
kguiaddons-qt5
ki18n-qt5
kwindowsystem-qt5
kcrash-qt5
kglobalaccel-qt5
kidletime-qt5
kimageformats-qt5
kitemmodels-qt5
kitemviews-qt5
kjs-qt5
kplotting-qt5
kwidgetsaddons-qt5
solid-qt5
)

for pkg in "${pkgs[@]}"; do
  pushd ${THISDIR}/../mingw-w64-${pkg}
  export KF5_VARIANT=$1
  rm -rf *pkg*xz src pkg
  makepkg-mingw -siLf --noconfirm || exit 1
  popd
done
